<style type="text/css">
    #ground{width: 100%; height: 40px; float: left;}
    #ground1{width: 40px; margin-right:20px; height: 40px; float: right;}
</style>
<?php
$arr = $id_book = $this->uri->segment(3);
$arr = explode('.', $arr);

if (count($arr) == 1) {
    $alert = '';
} else {
    $alert = 'confirm';
}
?>

<div id="blokreg">
    <?php
    $array = $this->uri->segment(3);
    $array = explode('.', $array);
    ?>
    <?php if (count($array) == 2): ?>
        <?php if ($array[1] == 'confirm'): ?>
            <div id="blokdata">
                <div id="ucapan">

                    <img src=<?php echo base_url()?>image/konfissued.jpg>

                </div>
            <?php endif ?>
        <?php endif ?>

        <div id="titlemerah"><p align="left">Booking</p></div>

        <table class="table table-hover table-bordered">
            <?php foreach ($rows as $booking): ?>
                <tbody> 
                    <tr>
                        <td style="width:200px;">Username:</td>
                        <td><?php echo get_user($booking->id_user) ?></td>
                    </tr>    
                    <tr>
                        <td>Maskapai:</td>
                        <td><?php echo $booking->airlines_name ?> <?php echo $booking->flight_number ?></td>
                    </tr>    
                    <tr>
                        <td>Price:</td>
                        <td>
                            <?php if ($booking->price_value == 0): ?>
                                IDR Request By Admin
                            <?php else: ?>
                                <?php echo get_money($booking->price_value) ?>    
                            <?php endif ?>
                        </td>
                    </tr>    
                    <tr>
                        <td>Fee:</td>
                        <td><?php echo get_money($booking->fee) ?></td>
                    </tr>    
                    <tr>
                        <td>Total:</td>
                        <td><?php echo get_money($booking->total) ?></td>
                    </tr>    
                    <tr>
                        <td>From:</td>
                        <td><?php echo get_airport($booking->from) . " ($booking->from)" ?></td>
                    </tr>    
                    <tr>
                        <td>To:</td>
                        <td><?php echo get_airport($booking->to) . " ($booking->to)" ?></td>
                    </tr>    
                    <tr>
                        <td>Depart:</td>
                        <td>JAM <?php echo $booking->simple_departure_time ?> / <?php echo get_tanggal($booking->date) ?></td>
                    </tr>    
                    <tr>
                        <td>Arrive:</td>
                        <td>JAM <?php echo $booking->simple_arrival_time ?> / <?php echo get_tanggal($booking->date) ?></td>
                    </tr>    
                    <tr>
                        <td>Class:</td>
                        <td><?php echo $booking->class ?></td>
                    </tr>    
                    <tr>
                        <td>Adult:</td>
                        <td><?php echo $booking->adult ?></td>
                    </tr>
                    <tr>
                        <td>Child:</td>
                        <td><?php echo $booking->child ?></td>
                    </tr>
                    <tr>
                        <td>Infant:</td>
                        <td><?php echo $booking->infant ?></td>
                    </tr>
                    <tr>
                        <td>Keterangan:</td>
                        <td><?php echo $booking->keterangan ?></td>
                    </tr>
                    <tr>
                        <td>Status:</td>
                        <td><?php echo get_status_color($booking->status) ?></td>
                    </tr>
                </tbody>
            <?php endforeach; ?>
        </table>

        <div id="titlemerah"><p align="left">Penumpang <?php echo $penumpang = $booking->adult + $booking->child + $booking->infant ?></p></div>

        <table class="table table-hover table-bordered">
            <?php $adults = get_booking_adult($booking->code) ?>
            <?php $no = 1 ?>
            <br />
            <?php foreach ($adults as $adult): ?>
                <b>Dewasa <?php if (count($adults) > 1) { ?><?php echo $no ?><?php } ?></b>

                <?php $no++ ?>
                <tbody>
                    <tr>
                        <td style="width:200px;">Nama Depan:</td>
                        <td><?php echo $adult->title_adult ?> <?php echo $adult->nama_depan ?> </td>
                    </tr>
                    <tr>
                        <td>Nama Belakang:</td>
                        <td><?php echo $adult->nama_belakang ?></td>
                    </tr>
                    <tr>
                        <td>Passport:</td>
                        <td><?php echo $adult->passport ?></td>
                    </tr>
                    <tr>
                        <td>Identitas:</td>
                        <td><?php echo $adult->identitas ?></td>
                    </tr></tbody>
            <?php endforeach; ?>
        </table>

        <?php if ($booking->child > 0): ?>
            <table class="table table-hover table-bordered">
                <?php $childs = get_booking_child($booking->code) ?>
                <?php $no = 1 ?>
                <?php foreach ($childs as $child): ?>
                    <b>Anak <?php if (count($childs) > 1) { ?><?php echo $no ?><?php } ?></b>
                    <?php $no++ ?>
                    <tbody>
                        <tr>
                            <td style="width:200px;">Nama Depan:</td>
                            <td><?php echo $child->title ?> <?php echo $child->nama_depan ?> </td>
                        </tr>
                        <tr>
                            <td>Nama Belakang:</td>
                            <td><?php echo $child->nama_belakang ?></td>
                        </tr>
                        <tr>
                            <td>Tanggal Lahir:</td>
                            <td><?php echo $child->tanggal . "-" . get_month($child->bulan) . "-" . $child->tahun ?></td>
                        </tr>
                    </tbody>
                <?php endforeach; ?>
            </table>
        <?php endif ?>

        <?php if ($booking->infant > 0): ?>
            <table class="table table-hover table-bordered">
                <?php $infants = get_booking_infant($booking->code) ?>
                <?php $no = 1 ?>
                <?php foreach ($infants as $infant): ?>
                    <b>Bayi <?php if (count($infants) > 1) { ?><?php echo $no ?><?php } ?></b>
                    <?php $no++ ?>
                    <tbody>
                        <tr>
                            <td style="width:200px;">Nama Depan:</td>
                            <td><?php echo $infant->title ?> <?php echo $infant->nama_depan ?> </td>
                        </tr>
                        <tr>
                            <td>Nama Belakang:</td>
                            <td><?php echo $infant->nama_belakang ?></td>
                        </tr>
                        <tr>
                            <td>Tanggal Lahir:</td>
                            <td><?php echo $infant->tanggal . "-" . get_month($infant->bulan) . "-" . $infant->tahun ?></td>
                        </tr>
                        <tr>
                            <td>Orang Tua:</td>
                            <td><?php echo get_orangtua($infant->orangtua) ?></td>
                        </tr>
                    </tbody>
                <?php endforeach; ?>
            </table>
        <?php endif ?>

        <div id="titlemerah"><p align="left">Data Kontak</p></div>
        <table class="table table-hover table-bordered">
            <tbody> <?php foreach ($rows as $booking): ?>

                    <tr>
                        <td style="width:200px;">Title Name:</td>
                        <td><?php echo $booking->title_dk ?> <?php echo $booking->nama_d_dk ?></td>
                    </tr>
                    <tr>
                        <td>Last Name:</td>
                        <td><?php echo $booking->nama_b_dk ?></td>
                    </tr>
                    <tr>
                        <td>Kode Negara:</td>
                        <td><?php echo $booking->kode_negara_dk ?></td>
                    </tr>
                    <tr>
                        <td>Kode Wilayah:</td>
                        <td><?php echo $booking->kode_wilayah_dk ?></td>
                    </tr>
                    <tr>
                        <td>No telephone:</td>
                        <td><?php echo $booking->nomor_telp_dk ?></td>
                    </tr>
                    <tr>
                        <td>Kode Negara:</td>
                        <td><?php echo $booking->kode_negara_s_dk ?></td>
                    </tr>
                    <tr>
                        <td>No Telephone Selular:</td>
                        <td><?php echo $booking->no_telp_selular_dk ?></td>
                    </tr>
                    <tr>
                        <td>Catatan:</td>
                        <td><?php echo $booking->catatan_dk ?></td>
                    </tr>
                    <tr>
                        <td>Booking Time:</td>
                        <td>JAM: <?php echo date('h:i / d F Y', strtotime($booking->date_create)) ?></td>
                    </tr>
                    <tr>
                        <td>Code Booking:</td>
                        <td><?php echo $booking->code_booking ?> </td>
                    </tr>

                <?php endforeach; ?>
        </table>
        <?php
        $deposit = get_total($deposits);
        ?>

        <?php if ($booking->status == 1): ?>
            <?php // echo anchor('costumers/confirm_booking/' . $booking->id.'.'.$booking->price_value.'.'.$deposit, 'Data Benar', 'class="btn btn-primary"') ?>
            <?php // echo form_open('costumers/confirm_booking') ?>

            <form method="post" action="<?php echo base_url() ?>costumers/confirm_booking" onSubmit="if(!confirm('Tiket akan diissue. Pastikan airline, nama penumpang, tujuan dan jam keberangkatan sudah benar. Setelah issue, deposit akan terkurangi. Tiket yang sudah diissued tidak dapat dibatalkan')){return false;}">
                <?php echo form_hidden('id', $booking->id); ?>
                <?php echo form_hidden('deposit', $deposit); ?>
                <?php echo form_hidden('total_price', $booking->total); ?>
                <?php echo form_hidden('code', $booking->code); ?>
                <?php echo form_hidden('keterangan', 'Issue ' . $booking->airlines_name . ' ' . $booking->code_booking); ?>
                <div id="ground">

                    <?php // echo form_submcostumers/confirm_bookingit('submit', 'Data Benar', 'class="btn btn-primary"'); ?>
                    <!--<form onsubmit="return confirm('Do you really want to submit the form?');" value="Submit" class="btn btn-primary">-->

                    <input type="submit" value="Data Benar" class="btn btn-primary"/>

                    <?php // echo form_close() ?>
            </form>
            <?php echo anchor('costumers/cancel_booking/' . $booking->id . '.' . $booking->code, 'Batal', array('target' => '_blank', 'class' => 'btn btn')) ?> 
        <?php elseif ($booking->status == 3): ?>
            <?php // echo anchor('costumers/download/' . $booking->file, "Show ISSUE", 'class="btn btn-primary"') ?>               
            <FORM>
                <!--<INPUT type="button" value="ISSUE" class="btn btn-primary" onClick="window.open('<?php // echo base_url() . 'costumers/file/' . $booking->file      ?>','mywindow','width=820,height=620')">-->
                <INPUT type="button" value="TIKET ANDA" class="btn btn-primary" onClick="window.open('https://docs.google.com/viewer?url=<?php echo base_url() . 'tiket/' . $booking->file ?>','mywindow','width=820,height=620')">
            </FORM> 
        <?php endif ?>    <?php if (!$booking->status == 0)  ?><div id="ground1"><?php echo anchor('costumers/status_issued', 'Back', 'class="btn btn"') ?></div></div>

</div>
